$(document).ready(function () {
    var products = [
        { src: "../images/dress1.jpg", desc: "红色裙子", link: "../商品详情/details.html" },
        { src: "../images/dress2.jpg", desc: "蓝色裙子", link: "../商品详情/details.html" },
        { src: "../images/dress3.jpg", desc: "绿色裙子", link: "../商品详情/details.html" },
        { src: "../images/dress4.jpg", desc: "黄色裙子", link: "../商品详情/details.html" }
    ];
    var index = 0;

    function rotateProduct() {
        var productLink = products[index].link;
        var $link = $('#product-link');

        $('#featured-products img').attr('src', products[index].src);
        
        $('#featured-products h3').text(products[index].desc);

        $link.attr('href', productLink);

        index = (index + 1) % products.length;
    }

    setInterval(rotateProduct, 3000);

    function updateTime() {
        var now = new Date();
        var timeString = now.toLocaleTimeString();
        $('#current-time').text(timeString);
    }

    setInterval(updateTime, 1000);
});